#ifndef MAINSCENE_H
#define MAINSCENE_H

#include <QTimer>
#include <QWidget>
#include "map.h"
#include <QPaintEvent>
#include <QPainter>
#include "heroplane.h"
#include "bullet.h"
#include "enemyplane.h"
#include <ctime>
#include "bomb.h"
#include <QKeyEvent>
#include<QApplication>
#include <QIcon>
#include <QMainWindow>
#include<QString>


class MainScene : public QWidget
{
    Q_OBJECT

public:
    MainScene(QWidget *parent = nullptr);
    ~MainScene();
    void initScene(); //初始化游戏场景

    void NewGame();
    void KeyPressed(int key);

    QTimer m_Timer;//定时器
public slots:
    //启动游戏，用于启动定时器对象
    void playGame();

public:
    //更新坐标
    void updatePosition();

    //绘图
    void paintEvent(QPaintEvent *event);

    //鼠标移动事件
    void mouseMoveEvent(QMouseEvent *event);

    //敌机出场
    void enemyToScene();

    //碰撞检测
    void collisionDetection();

    void keyPressEvent(QKeyEvent *event); //键盘按下事件

public:
    //地图对象
    Map m_map;

    //飞机对象
    HeroPlane m_hero;

    //敌机
    EnemyPlane m_enemys[ENEMY_NUM];

    //敌机出场时间间隔
    int m_EnemyRecorder;

    //爆炸数组
    Bomb m_bombs[BOMB_NUM];

    int keyPressed;

    int Score; //得分
    QString scoreLabel;  //显示得分榜

    bool blsOver=1;


};
#endif // MAINSCENE_H
